import http from '@src/util/http';
let prefix = '/api/im';
// let prefix = ''

const ruleHeader = '/api/linkc';
/**
 * 查询im配置项的接口
 * @param {*} params
 */
export function getTenantImSetting() {
  return http.get(`${prefix}/outside/im/imAccount/getTenantImSetting`);
}
/**
 * im配置项的编辑接口
 * @param {*} params
 */
export function modifyImSetting(params = {}) {
  return http.post(`${prefix}/outside/im/imAccount/modifyImSetting`, params);
}

/**
 * 编辑在线客服人员(包括编辑、绑定、解绑)
 * @param {*} params
 */
export function modifyCustomerService(params = {}) {
  return http.post(
    `${prefix}/outside/im/imCustomerService/modifyCustomerService`,
    params
  );
}

/**
 * 获取当前租户的所有在线客服
 * @param {*} params
 */
export function getAllCustomerService() {
  return http.get(
    `${prefix}/outside/im/imCustomerService/getAllCustomerService`
  );
}

/**
 * 绑定在线客服
 * @param {*} params
 */
export function bindCustomerService(params = {}) {
  return http.post(
    `${prefix}/outside/im/imCustomerService/bindCustomerService`,
    params
  );
}

/**
 * 解绑在线客服
 * @param {*} params
 */
export function unBindCustomerService(params = {}) {
  return http.post(
    `${prefix}/outside/im/imCustomerService/unBindCustomerService`,
    params
  );
}

/**
 * @description IM列表
 * @param {Object} params 参数对象
 */
export function queryConversationList(params = {}) {
  return http.post(
    `${prefix}/outside/im/conversation/queryConversationList`,
    params
  );
}

/**
 * @description 列表页/详情页-删除
 */
export function removeConversations(params = {}) {
  return http.post(
    `${prefix}/outside/im/conversation/removeConversations`,
    params
  );
}

/**
 * @description 查询当前客服下所有未关闭的会话
 */
export function getOpenConversation(params = {}) {
  return http.post(
    `${prefix}/outside/im/conversation/getOpenConversation`,
    params
  );
}

/**
 * @description 关闭选中的会话
 */
export function closeConversation(params = {}) {
  return http.get(
    `${prefix}/outside/im/conversation/closeConversation`,
    params
  );
}

/**
 * @description 获取咨询人和客服的环信ID
 */
export function getImIdByConversation(params = {}) {
  return http.get(
    `${prefix}/outside/im/conversation/getImIdByConversation`,
    params
  );
}

/**
 * @description 查询会话的消息记录
 */
export function queryChatRecord(params = {}) {
  return http.post(`${prefix}/outside/im/message/queryChatRecord`, params);
}

/**
 * @description 新增会话消息
 */
export function addMessageInfo(params = {}) {
  return http.post(`${prefix}/outside/im/message/addMessageInfo`, params);
}

/**
 * @description 获取当前会话下的客户信息
 */
export function getCustomerInfo(params = {}) {
  return http.get(`${prefix}/outside/im/conversation/getCustomerInfo`, params);
}

/**
 * @description 获取会话详情
 */
export function getConversationInfo(params = {}) {
  return http.get(
    `${prefix}/outside/im/conversation/getConversationInfo`,
    params
  );
}

/**
 * @description 获取当前客户下的服务记录
 */
export function getServiceRecord(params = {}) {
  return http.get(`${prefix}/outside/im/conversation/getServiceRecord`, params);
}

/**
 *  获取config
 */
export function getConfig(params) {
  return http.get(`${prefix}/outside/im/config/getConfig`, params);
}

/**
 * 更新会话消息的状态
 */
export function editMessageInfo(params) {
  return http.post(`${prefix}/outside/im/message/editMessageInfo`, params);
}

/**
 * 更新当前会话消息的状态
 */
export function editMessageByConversation(params) {
  return http.post(
    `${prefix}/outside/im/message/editMessageByConversation`,
    params
  );
}

/**
 * 获取微信客服列表
 */
export function getWeChatKFList(params) {
  return http.get(`${prefix}/outside/im/weChat/getWeChatKFList`, params);
}

/**
 * 编辑微信客服
 */
export function modifyWeChatKF(params) {
  return http.post(`${prefix}/outside/im/weChat/modifyWeChatKF`, params);
}

/**
 * 订阅客服
 */
export function subscribeKF(params) {
  return http.post(`${prefix}/outside/im/weChat/subscribeKF`, params);
}

/**
 * 获取授权结果
 */
export function getAuthFlag(params) {
  return http.get(`${prefix}/outside/im/corp/getAuthFlag`, params);
}

/**
 * 租户关联corpId
 */
export function relationCorp(params) {
  return http.post(`${prefix}/outside/im/corp/relationCorp`, params);
}

/**
 * 获取所有投放渠道
 */
export function getAllPutChannel(params) {
  return http.get(`${prefix}/outside/im/channel/getAllPutChannel`, params);
}

/**
 * 获取添加投放渠道的客服链接的选项值
 */
export function getRelationOptions(params) {
  return http.get(`${prefix}/outside/im/channel/getRelationOptions`, params);
}

/**
 * 添加投放渠道
 */
export function addPutChannel(params) {
  return http.post(`${prefix}/outside/im/channel/addPutChannel`, params);
}

/**
 * 编辑投放渠道
 */
export function modifyPutChannel(params) {
  return http.post(`${prefix}/outside/im/channel/modifyPutChannel`, params);
}

/**
 * 删除投放渠道
 */
export function removePutChannel(params) {
  return http.post(`${prefix}/outside/im/channel/removePutChannel`, params);
}

/**
 * 会话分配规则列表
 */
export function getDistributeRules(params) {
  return http.get(`${prefix}/outside/im/rules/getDistributeRules`, params);
}

/**
 * 添加分配规则
 */
export function addDistributeRule(params) {
  return http.post(`${prefix}/outside/im/rules/addDistributeRule`, params);
}

/**
 * 获取单条规则详情
 */
export function getDistributeRuleInfo(params) {
  return http.get(`${prefix}/outside/im/rules/getDistributeRuleInfo`, params);
}

/**
 * 编辑分配规则
 */
export function modifyDistributeRule(params) {
  return http.post(`${prefix}/outside/im/rules/modifyDistributeRule`, params);
}

/**
 * 调整分配规则优先级
 */
export function adjustLevel(params) {
  return http.post(`${prefix}/outside/im/rules/adjustLevel`, params);
}

/**
 * 启用/禁用分配规则
 */
export function modifyDistributeRuleEnabled(params) {
  return http.post(
    `${prefix}/outside/im/rules/modifyDistributeRuleEnabled`,
    params
  );
}

/**
 * 删除分配规则
 */
export function removeDistributeRule(params) {
  return http.post(`${prefix}/outside/im/rules/removeDistributeRule`, params);
}

/**
 * 按客户信息时的客户字段下拉列表
 */
export function queryApplyOptions(params) {
  return http.get(
    `${ruleHeader}/outside/superCode/rule/queryApplyOptions`,
    params
  );
}

/**
 * 获取配置的专员与客户群
 */
export function getUpgradeServiceConfig(params) {
  return http.get(
    `${prefix}/outside/im/weChat/getUpgradeServiceConfig`,
    params
  );
}

/**
 * 为客户升级为专员或客户群服务
 */
export function upgradeService(params) {
  return http.post(`${prefix}/outside/im/weChat/upgradeService`, params);
}

/**
 * 为客户升级为专员或客户群服务
 */
export function specifyService(params) {
  return http.post(`${prefix}/outside/im/weChat/specifyService`, params);
}

/**
 * 会话转交
 */
export function conversationForwarding(params) {
  return http.post(
    `${prefix}/outside/im/conversation/conversationForwarding`,
    params
  );
}

/**
 * 转人工
 */
export function transferToLabor(params) {
  return http.post(
    `${prefix}/outside/im/conversation/transferToLabor`,
    params
  );
}
/**
 * 根据会话ID获取会话详情中的动态信息
 */
export function getDynamicContent(params) {
  return http.get(
    `${prefix}/outside/im/conversation/getDynamicContent`,
    params
  );
}

/**
 * 会话置顶
 */
export function conversationTop(params) {
  return http.get(`${prefix}/outside/im/conversation/conversationTop`, params);
}

/**
 * 取消会话置顶
 */
export function cancelConversationTop(params) {
  return http.get(
    `${prefix}/outside/im/conversation/cancelConversationTop`,
    params
  );
}

/**
 * PC端获取未读消息统计
 */
export function getTotalUnreadCount(params) {
  return http.get(`${prefix}/outside/im/message/getTotalUnreadCount`, params);
}

/**
 * @description 获取服务备注表单模板
 * @returns
 */
export function getRemarkTemplate() {
  return http.get(
    `${prefix}/outside/im/serviceRemarkTemplate/getTemplateConfig`
  );
}

/**
 * @description 保存服务备注表单模板
 * @returns
 */
export async function saveRemarkTemplate(params) {
  const res = await http.post(
    `${prefix}/outside/im/serviceRemarkTemplate/saveOrUpdate`,
    params
  );
  if (!res.success) return Promise.reject(res);
  return res;
}

/*
 * 获取当前客服的工作状态
 */
export function getCustomerServiceStatus(params) {
  return http.get(
    `${prefix}/outside/im/imCustomerService/getCustomerServiceStatus`,
    params
  );
}

/**
 * 修改客服的工作状态
 */
export function modifyCustomerServiceStatus(params) {
  return http.get(
    `${prefix}/outside/im/imCustomerService/modifyCustomerServiceStatus`,
    params
  );
}
/*
 * PC端客服发起视频通话前获取房间信息
 */
export function createNewRoom(params) {
  return http.post(`${prefix}/outside/im/videoCall/createNewRoom`, params);
}

/**
 * 结束会话
 */
export function finished(params) {
  return http.post(`${prefix}/outside/im/conversation/finished`, params);
}

/**
 * 查询租户的服务备注模板
 */
export function getTemplateByTenantId(params) {
  return http.get(
    `${prefix}/outside/im/serviceRemarkTemplate/getTemplateFilter`,
    params
  );
}

/**
 * 根据会话查询服务备注
 */
export function getInfoByBizId(params) {
  return http.get(`${prefix}/outside/im/service/remark/getInfoByBizId`, params);
}

/**
 *  查询租户服务备注模板中的咨询分类
 */
export function getConsultTypeList(params) {
  return http.get(
    `${prefix}/outside/im/serviceRemarkTemplate/getConsultTypeList`,
    params
  );
}

/**
 *  新增服务备注信息
 */
export function SaveInfo(params, query) {
  return http.post(`${prefix}/outside/im/service/remark/saveInfo${query || ''}`, params);
}

/**
 *  编辑服务备注
 */
export function UpdateInfo(params, query) {
  return http.post(`${prefix}/outside/im/service/remark/updateInfo${query || ''}`, params);
}

/**
 * 新建快捷回复
 */
export function addQuickReply(params) {
  return http.post(
    `${prefix}/outside/im/pc/imQuicklyReply/addQuickReply`,
    params
  );
}

/**
 * 删除快捷回复
 */
export function deleteQuickReply(params) {
  return http.get(
    `${prefix}/outside/im/pc/imQuicklyReply/deleteQuickReply`,
    params
  );
}

/**
 * 获取当前用户快捷回复列表
 */
export function getQuickReplyList(params) {
  return http.get(
    `${prefix}/outside/im/pc/imQuicklyReply/getQuickReplyList`,
    params
  );
}

/**
 * 编辑快捷回复
 */
export function updateQuickReply(params) {
  return http.post(
    `${prefix}/outside/im/pc/imQuicklyReply/updateQuickReply`,
    params
  );
}
/*
 * 获取指派会话列表
 */
export function getLineConversationList(params) {
  return http.post(
    `${prefix}/outside/im/conversation/getLineConversationList`,
    params
  );
}

/**
 * 指派会话
 */
export function conversationTransfer(params) {
  return http.post(
    `${prefix}/outside/im/conversation/conversationTransfer`,
    params
  );
}
/**
 * 根据事件查询关联会话列表-分页查询
 */
export function getListByBizInfo(params) {
  return http.get(`${prefix}/outside/im/bizRel/getListByBizInfo`, params);
}
/**
 * 获取当前客服的会话数量和排队数量
 */
export function getConversationDealNum(params) {
  return http.get(
    `${prefix}/outside/im/conversation/getConversationDealNum`,
    params
  );
}

/**
 * 保存会话与事件的业务关联
 */
export function saveBizRel(params) {
  return http.post(`${prefix}/outside/im/bizRel/saveBizRel`, params);
}

/**
 * PC端客服离开/关闭房间
 */
export function leaveRoom(params) {
  return http.post(`${prefix}/outside/im/videoCall/leaveRoom`, params);
}

/**
 * IM配置
 */
export function imGetConfig(params) {
  return http.get('/setting/im/getConfig', params);
}

/**
 * 获取产品权限
 */
export function getOperationalData(params) {
  return http.get('/customer/product/getOperationalData', params);
}
/**
 * 获取PASS应用列表
 */
export function passList() {
  return http.get('/api/paas/outside/pc/app/getAccessApp');
}

/**
 * 判断当前登录账号是否为客服坐席
 */
export function isCustomerService(params) {
  return http.get(`${prefix}/outside/im/imCustomerService/isCustomerService`, params);
}

/**
 * 获取会话服务记录列表
 */
export function getServiceRecordV2(params) {
  return http.get(`${prefix}/outside/im/bizRel/getServiceRecordV2`, params);
}

/**
 * PC端获取在线客服的开通状态
 */
export function getImOpenState (params) {
  return http.get(`${prefix}/outside/im/imAccount/getImOpenState`, params);
}

/**
 * PC端获取在线客服查总开关是否打开
 */
export function getImEnabled (params) {
  return http.get(`${prefix}/outside/im/imAccount/getImEnabled`, params);
}

/**
 * pc端知识库分享到会话
 */
export function shareWiki (params) {
  return http.post(`${prefix}/outside/im/message/shareWiki`, params);
}

/**
 * pc端邀请游客登录
 */
export function inviteTouristLogin (params) {
  return http.post(`${prefix}/outside/im/message/inviteTouristLogin`, params);
}

/**
 * 内部IM获取个人聊天列表
 */
export function queryPersonalChatList (params) {
  return http.post(`${prefix}/outside/pc/chat/singleChat/queryPersonalChatList`, params);
}

/**
 * 发起单聊,返回咨询人的信息
 */
export function startSingleChat (params) {
  return http.post(`${prefix}/outside/pc/chat/singleChat/startSingleChat`, params);
}

/**
 * 发起群聊,返回咨询人的信息
 */
export function startChat (params) {
  return http.post(`${prefix}/outside/pc/chat/singleChat/startChat`, params);
}

/**
 * 发送消息-基础消息
 */
export function sendSingleMessage (params) {
  return http.post(`${prefix}/outside/pc/chat/chatMessage/sendMessage`, params);
}

/**
 * 批量消息已读
 */
export function chatMessageRead (params) {
  return http.post(`${prefix}/outside/pc/chat/chatMessage/chatMessageRead`, params);
}

/**
 * 查询聊天记录
 */
export function queryChatRecord_inside (params) {
  return http.post(`${prefix}/outside/pc/chat/chatMessage/queryChatRecord`, params);
}

/**
 * 发送单聊消息-业务消息
 */
export function sendBizMessage (params) {
  return http.post(`${prefix}/outside/pc/chat/chatMessage/sendMessage`, params);
}

/**
 * 查询业务详情
 */
export function queryBizMessageContent (params) {
  return http.post(`${prefix}/outside/pc/chat/chatMessage/queryBizMessageContent`, params);
}

/**
 * 内部Im消息置顶
 */
export function chatTop (params) {
  return http.post(`${prefix}/outside/pc/chat/singleChat/chatTop`, params);
}

/**
 * 内部Im取消消息置顶
 */
export function chatCancelTop (params) {
  return http.post(`${prefix}/outside/pc/chat/singleChat/chatCancelTop`, params);
}

/**
 * 内部Im隐藏会话
 */
export function chatDisplay (params) {
  return http.post(`${prefix}/outside/pc/chat/singleChat/chatDisplay`, params);
}

/**
 * 客服发送文本新消息（环信、微信客服通用）
 */
export function customerServiceSendNewMessage (params) {
  return http.post(`${prefix}/outside/im/message/customerServiceSendNewMessage`, params);
}

/**
 *  未知客户保存信息
 */
export function unknownUserRelationLinkman (params) {
  return http.post(`${prefix}/outside/im/user/unknownUserRelationLinkman`, params);
}

/**
 * 获取群聊详情
 */
export function getGroupChatDetails (params) {
  return http.get(`${prefix}/outside/pc/chat/groupChat/getGroupChatDetails`, params);
}

/**
 * 变更群聊基本信息：群名称、头像等
 */
export function editGroupChatInfo (params) {
  return http.post(`${prefix}/outside/pc/chat/groupChat/editGroupChatInfo`, params);
}

/**
 * 管理群成员
 */
export function editMemberUser (params) {
  return http.post(`${prefix}/outside/pc/chat/groupChat/editMemberUser`, params);
}

/**
 * 群主解散群
 */
export function dissolution (params) {
  return http.get(`${prefix}/outside/pc/chat/groupChat/dissolution`, params);
}

/**
 * 退出群聊
 */
export function signOut (params) {
  return http.get(`${prefix}/outside/pc/chat/groupChat/signOut`, params);
}

/**
 * 发送离线消息
 */
 export function offLineNotify (params) {
  return http.post(`${prefix}/outside/im/message/offLineNotify`, params);
}

/**
 * 查询离线消息方式
 */
 export function getNotifyMode (params) {
  return http.get(`${prefix}/outside/im/message/getNotifyMode`, params);
}

/**
 * 客服撤回消息
 */
 export function customerServiceMessageRecall (params) {
  return http.post(`${prefix}/outside/im/message/customerServiceMessageRecall`, params);
}

/**
 * 客服端获取客户的历史会话及消息记录
 */
 export function getCustomerHistoryConversation (params) {
  return http.get(`${prefix}/outside/im/conversation/getCustomerHistoryConversation`, params);
}

/**
 * 获取在线客服搜索栏
 * @param {*} params
 */
 export function comprehensiveSearch(params = {}) {
  return http.post(
    `${prefix}/outside/im/conversation/comprehensiveSearch`,
    params
  );
}

/**
 * 发起咨询前信息获取
 * @param {*} params
 */
export function getTenantUserSponsorInfo(params = {}) {
  return http.get(
    `${prefix}/outside/im/conversation/getTenantUserSponsorInfo`,
    params
  );
}

/**
 * 获取邮件列表
 * @param {*} params
 */
export function getEmailList(params = {}) {
  return http.post(
    `${prefix}/outside/email/list`,
    params
  );
}

/**
 * 获取邮件详情
 * @param {*} params
 */
export function getEmailInfo(params = {}) {
  return http.get(
    `${prefix}/outside/email/info`,
    params
  );
}

/**
 * 获取历史邮件
 * @param {*} params
 */
export function getEmailHistoryList(params = {}) {
  return http.get(
    `${prefix}/outside/email/historyList`,
    params
  );
}

/**
 * 获取客户最近发的邮件
 * @param {*} params
 */
export function getNewEmail(params = {}) {
  return http.get(
    `${prefix}/outside/email/conversation/getNewEmail`,
    params
  );
}

/**
 * 客服端获取客户的历史会话及消息记录
 */
export function getLineConversationNum (params) {
  return http.get(`${prefix}/outside/im/conversation/getLineConversationNum`, params);
}

/**
 * 发送报表消息
 */
export function sendReportMessage (params) {
  return http.post(`${prefix}/outside/pc/chat/chatMessage/sendMessage`, params);
}

/**
 * 获取报表消息内容
 */
export function getReportMessageContent (params) {
  return http.get(`/api/dataware/outside/custom/chart/thumbnailUrl/${params.id}`);
}